#!/bin/bash

function runNode() {
    port=$1
    PID=`ps -ef | grep -v grep | grep "/blog/blog-node/app.js -p $port" | awk '{print $2}'`
    if [ ! $PID ]; then
        #echo "  kill old process grep app.js -p $port begin "
        #$PID | sudo xargs kill -9

        echo "  run node app.js -p $port "
    fi 
}

if [[ $1 == "-h" ]]
then
echo ""
echo ""
exit
fi

echo "  run the blog... "
echo ""

if [[ ! -e /blog/blog-node ]]
then
        echo "  error: no onepiece dir!!"
        exit
fi

if [[ ! -e /blog/blog-node/app.js ]]
then
        echo "  error: no app.js file!!"
        exit
fi



cd /blog/blog-node
runNode 10000
#runNode 9700
#runNode 9800
#runNode 9900
#runNode 9901

echo "  run blog is end~ =_=!! "



